<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="js/vue.js"></script>
		<!-- 引入插件 -->
		<script src="js/echarts.min.js"></script>
	</head>
	<style>
		/* 2.设置尺寸 */
		#chart1,#chart2,#chart3,#chart4{
			width: 24%;
			height: 500px;
			border: 1px solid #000;
			display: inline-block;	/* 行内块级 */
		}
	</style>
	<body>
		<div id='app'>
			<!-- 1.准备画布 -->
			<div id="chart1"></div>
			<div id="chart2"></div>
			<div id="chart3"></div>
			<div id="chart4"></div>
		</div>
		<script>
			Vue.createApp({
				data(){
					return{
					
					}
				},
				created() {
					
				},
				mounted() {		//画布渲染完成
					this.chart1()	//4.调用画图方法
					this.chart2()
					this.chart3()
					this.chart4()
				},
				methods:{
					chart1(){	//3.画图方法
						var chartDom = document.getElementById('chart1');
						var myChart = echarts.init(chartDom,'dark');
						var option;
						
						option = {
						  xAxis: {
						    type: 'category',
						    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
						  },
						  yAxis: {
						    type: 'value'
						  },
						  series: [
						    {
						      data: [150, 230, 224, 218, 135, 147, 260],
						      type: 'line'
						    }
						  ]
						};
						option && myChart.setOption(option);
						//浏览器窗口尺寸变化时，图标也变化
						window.addEventListener('resize',()=>{
								myChart.resize()
						})
					},
					chart2(){
						var chartDom = document.getElementById('chart2');
						var myChart = echarts.init(chartDom);
						var option;
						
						option = {
						  xAxis: {
						    type: 'category',
						    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
						  },
						  yAxis: {
						    type: 'value'
						  },
						  series: [
						    {
						      data: [120, 200, 150, 80, 70, 110, 130],
						      type: 'bar',
						      showBackground: true,
						      backgroundStyle: {
						        color: 'rgba(180, 180, 180, 0.2)'
						      }
						    }
						  ]
						};
						
						option && myChart.setOption(option);
						//浏览器窗口尺寸变化时，图标也变化
						window.addEventListener('resize',()=>{
								myChart.resize()
						})
					},
					chart3(){
						var chartDom = document.getElementById('chart3');
						var myChart = echarts.init(chartDom);
						var option;
						
						option = {
						  title: {
						    text: 'Referer of a Website',
						    subtext: 'Fake Data',
						    left: 'center'
						  },
						  tooltip: {
						    trigger: 'item'
						  },
						  legend: {
						    orient: 'vertical',
						    left: 'left'
						  },
						  series: [
						    {
						      name: 'Access From',
						      type: 'pie',
						      radius: '50%',
						      data: [
						        { value: 1048, name: 'Search Engine' },
						        { value: 735, name: 'Direct' },
						        { value: 580, name: 'Email' },
						        { value: 484, name: 'Union Ads' },
						        { value: 300, name: 'Video Ads' }
						      ],
						      emphasis: {
						        itemStyle: {
						          shadowBlur: 10,
						          shadowOffsetX: 0,
						          shadowColor: 'rgba(0, 0, 0, 0.5)'
						        }
						      }
						    }
						  ]
						};
						
						option && myChart.setOption(option);
						//浏览器窗口尺寸变化时，图标也变化
						window.addEventListener('resize',()=>{
								myChart.resize()
						})

					},
					chart4(){
						
						var chartDom = document.getElementById('chart4');
						var myChart = echarts.init(chartDom);
						var option;
						
						option = {
						  title: {
						    text: 'Stacked Area Chart'
						  },
						  tooltip: {
						    trigger: 'axis',
						    axisPointer: {
						      type: 'cross',
						      label: {
						        backgroundColor: '#6a7985'
						      }
						    }
						  },
						  legend: {
						    data: ['Email', 'Union Ads', 'Video Ads', 'Direct', 'Search Engine']
						  },
						  toolbox: {
						    feature: {
						      saveAsImage: {}
						    }
						  },
						  grid: {
						    left: '3%',
						    right: '4%',
						    bottom: '3%',
						    containLabel: true
						  },
						  xAxis: [
						    {
						      type: 'category',
						      boundaryGap: false,
						      data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
						    }
						  ],
						  yAxis: [
						    {
						      type: 'value'
						    }
						  ],
						  series: [
						    {
						      name: 'Email',
						      type: 'line',
						      stack: 'Total',
						      areaStyle: {},
						      emphasis: {
						        focus: 'series'
						      },
						      data: [120, 132, 101, 134, 90, 230, 210]
						    },
						    {
						      name: 'Union Ads',
						      type: 'line',
						      stack: 'Total',
						      areaStyle: {},
						      emphasis: {
						        focus: 'series'
						      },
						      data: [220, 182, 191, 234, 290, 330, 310]
						    },
						    {
						      name: 'Video Ads',
						      type: 'line',
						      stack: 'Total',
						      areaStyle: {},
						      emphasis: {
						        focus: 'series'
						      },
						      data: [150, 232, 201, 154, 190, 330, 410]
						    },
						    {
						      name: 'Direct',
						      type: 'line',
						      stack: 'Total',
						      areaStyle: {},
						      emphasis: {
						        focus: 'series'
						      },
						      data: [320, 332, 301, 334, 390, 330, 320]
						    },
						    {
						      name: 'Search Engine',
						      type: 'line',
						      stack: 'Total',
						      label: {
						        show: true,
						        position: 'top'
						      },
						      areaStyle: {},
						      emphasis: {
						        focus: 'series'
						      },
						      data: [820, 932, 901, 934, 1290, 1330, 1320]
						    }
						  ]
						};
						
						option && myChart.setOption(option);
						//浏览器窗口尺寸变化时，图标也变化
						window.addEventListener('resize',()=>{
								myChart.resize()
						})
					}
				}
			}).mount('#app')
		</script>
	</body>
</html>